package com.tv189.springbatchtest.stopsteplisten;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;

/**
 * @ClassName: StopStepListener
 * @Description: TODO
 * @Author: 19202
 * @Date: 2025/6/2 12:55
 * @Version 1.0
 **/
public class StopStepListener implements StepExecutionListener {
    /**
     * @param stepExecution
     */
    @Override
    public void beforeStep(StepExecution stepExecution) {

    }

    /**
     * @param stepExecution
     * @return
     */
    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        if (ResourceCount.readCount != ResourceCount.totalCount) {
            return ExitStatus.STOPPED;
        }
        return stepExecution.getExitStatus();
    }
}
